package hapi.geom;

import hapi.math.Vector2D;

class Pie {
	
	public var center:Vector2D;
	public var radius:Float;
	public var direction:Vector2D;
	public var angle:Float;
	
	public function new(center, radius, direction, angle){
		this.center = center;
		this.radius = radius;
		this.direction = direction;
		this.angle = angle;
	}
	
	public function contains(p){
		if(center.distance(p) <= radius){
			return Vector2D.angleBetween(p.minusNew(center),direction) < angle/2;
		}else
			return false;
	}
	
	public function clone(){
		return new Pie(center.clone(), radius, direction.clone(), angle );
	}
	
	public function toString(){
		return "Pie("+center+","+radius+","+direction+","+angle+")";
	}
}